*****************************************************************************************************************************************************
* PROJECT: 		Exposure to the COVID-19 Stock Market Crash and its Effect on Household Expectations
* DATE: 		Nov 2020
* CONTENT: 		TABLES
* AUTHORS: 		Tobin Hanspal, Johannes Wohlfart, Anni Weber
*****************************************************************************************************************************************************

		clear all
		set scheme lean2
		global pm = char(177)
		set more off
		gl date = c(current_date)
		graph set window fontface "cmr10"
		
		
* set cd as /Replication_files_HanspalWeberWohlfart2020/


*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~						
** Table 1
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	
use data/processed/data_1, clear 

foreach var of varlist expec_debthigher expec_morehrs expec_retirlater never_ownwealth never_owninc ///
realized_anychangestocks realized_morestocks realized_lessstocks planned_anychangestocks planned_morestocks planned_lessstocks {

gen `var'_00=100* `var' 

}
* 
		
gen republican1=republican 
replace republican1=1 if other_party==1 


keep if control_pure==1 |control_fincrisis==1 | control_dotcom==1 | control_black==1 
keep if stockinvestor==1




global controls 	ln_hhnetinc hhnetinc19_NR ///
					ln_finwealth_Jan20 share_retir_finwealth ///
					ln_realestate_lvl realestJan20_NR		///
					ln_debt_lvl  debtJan20_NR ///
					stockexperience  ///
					i.agecat male married separated_divorced widowed ///	
					highschool some_college_associate_degree atleast_bachelor  ///
					mainearner_alone z_constrained  self_empl retired unempl empl_other ///
					republican other_party NR_party  ///
					z_decisionmaker  ///
					i.region ///
					i.svydate i.treatment 
		


loc experiments "realized_anychangestocks_00 realized_morestocks_00 realized_lessstocks_00 planned_anychangestocks_00 planned_morestocks_00 planned_lessstocks_00"
loc experiments1 "realized_anychangestocks_00 realized_morestocks_00 realized_lessstocks_00"
loc experiments2 "planned_anychangestocks_00 planned_morestocks_00 planned_lessstocks_00"


preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore

loc colnum = 1
loc colnames ""


foreach choice in `experiments1' {
reg `choice'  ///
		del_hhnetinc_perc_tr02   ///
		fincrisis dotcom bm fincrisis_big dotcom_big bm_big   ///
		riskshare_ofinwealth_Jan20 riskshare_retirwealth_Jan20 ///
		$controls ///
		, robust 
		
local N=e(N)
local r2=round(e(r2_a),.001)

sigstar del_hhnetinc_perc_tr02, prec(3)
estadd loc thisstat2 = "`r(bstar)'": col`colnum'
estadd loc thisstat3 = "`r(sestar)'": col`colnum'

*sigstar del_retir_perc_tr02, prec(3)
*estadd loc thisstat4 = "`r(bstar)'": col`colnum'
*estadd loc thisstat5 = "`r(sestar)'": col`colnum'

*sigstar del_ofin_perc_tr02, prec(3)
*estadd loc thisstat6 = "`r(bstar)'": col`colnum'
*estadd loc thisstat7 = "`r(sestar)'": col`colnum'

sigstar ln_finwealth_Jan20, prec(3)
estadd loc thisstat9 = "`r(bstar)'": col`colnum'
estadd loc thisstat10 = "`r(sestar)'": col`colnum'

sigstar riskshare_retirwealth_Jan20, prec(3)
estadd loc thisstat11 = "`r(bstar)'": col`colnum'
estadd loc thisstat12 = "`r(sestar)'": col`colnum'

sigstar riskshare_ofinwealth_Jan20, prec(3)
estadd loc thisstat13 = "`r(bstar)'": col`colnum'
estadd loc thisstat14 = "`r(sestar)'": col`colnum'

sigstar share_retir_finwealth, prec(3)
estadd loc thisstat15 = "`r(bstar)'": col`colnum'
estadd loc thisstat16 = "`r(sestar)'": col`colnum'

sigstar fincrisis, prec(3)
estadd loc thisstat18 = "`r(bstar)'": col`colnum'
estadd loc thisstat19 = "`r(sestar)'": col`colnum'

sigstar fincrisis_big, prec(3)
estadd loc thisstat20 = "`r(bstar)'": col`colnum'
estadd loc thisstat21 = "`r(sestar)'": col`colnum'

sigstar dotcom, prec(3)
estadd loc thisstat22 = "`r(bstar)'": col`colnum'
estadd loc thisstat23 = "`r(sestar)'": col`colnum'

sigstar dotcom_big, prec(3)
estadd loc thisstat24 = "`r(bstar)'": col`colnum'
estadd loc thisstat25 = "`r(sestar)'": col`colnum'

sigstar bm, prec(3)
estadd loc thisstat26 = "`r(bstar)'": col`colnum'
estadd loc thisstat27 = "`r(sestar)'": col`colnum'

sigstar bm_big, prec(3)
estadd loc thisstat28 = "`r(bstar)'": col`colnum'
estadd loc thisstat29 = "`r(sestar)'": col`colnum'

sigstar male, prec(3)
estadd loc thisstat31 = "`r(bstar)'": col`colnum'
estadd loc thisstat32 = "`r(sestar)'": col`colnum'

sigstar atleast_bachelor, prec(3)
estadd loc thisstat33 = "`r(bstar)'": col`colnum'
estadd loc thisstat34 = "`r(sestar)'": col`colnum'

sigstar republican, prec(3)
estadd loc thisstat35 = "`r(bstar)'": col`colnum'
estadd loc thisstat36 = "`r(sestar)'": col`colnum'

estadd loc thisstat38 "Yes": col`colnum'
estadd loc thisstat39= `r2': col`colnum'
estadd loc thisstat40 = `N': col`colnum'

loc ++colnum
loc colnames "`colnames' `"`: var la `choice''"'"

}



foreach choice in `experiments2' {
reg `choice'  ///
		del_hhnetinc_perc_tr02 del_retir_perc_tr02  del_ofin_perc_tr02 ///
		fincrisis dotcom bm fincrisis_big dotcom_big bm_big   ///
		riskshare_ofinwealth_Jan20 riskshare_retirwealth_Jan20 ///
		$controls ///
		, robust 
		
local N=e(N)
local r2=round(e(r2_a),.001)

sigstar del_hhnetinc_perc_tr02, prec(3)
estadd loc thisstat2 = "`r(bstar)'": col`colnum'
estadd loc thisstat3 = "`r(sestar)'": col`colnum'

sigstar del_retir_perc_tr02, prec(3)
estadd loc thisstat4 = "`r(bstar)'": col`colnum'
estadd loc thisstat5 = "`r(sestar)'": col`colnum'

sigstar del_ofin_perc_tr02, prec(3)
estadd loc thisstat6 = "`r(bstar)'": col`colnum'
estadd loc thisstat7 = "`r(sestar)'": col`colnum'

sigstar ln_finwealth_Jan20, prec(3)
estadd loc thisstat9 = "`r(bstar)'": col`colnum'
estadd loc thisstat10 = "`r(sestar)'": col`colnum'

sigstar riskshare_retirwealth_Jan20, prec(3)
estadd loc thisstat11 = "`r(bstar)'": col`colnum'
estadd loc thisstat12 = "`r(sestar)'": col`colnum'

sigstar riskshare_ofinwealth_Jan20, prec(3)
estadd loc thisstat13 = "`r(bstar)'": col`colnum'
estadd loc thisstat14 = "`r(sestar)'": col`colnum'

sigstar share_retir_finwealth, prec(3)
estadd loc thisstat15 = "`r(bstar)'": col`colnum'
estadd loc thisstat16 = "`r(sestar)'": col`colnum'

sigstar fincrisis, prec(3)
estadd loc thisstat18 = "`r(bstar)'": col`colnum'
estadd loc thisstat19 = "`r(sestar)'": col`colnum'

sigstar fincrisis_big, prec(3)
estadd loc thisstat20 = "`r(bstar)'": col`colnum'
estadd loc thisstat21 = "`r(sestar)'": col`colnum'

sigstar dotcom, prec(3)
estadd loc thisstat22 = "`r(bstar)'": col`colnum'
estadd loc thisstat23 = "`r(sestar)'": col`colnum'

sigstar dotcom_big, prec(3)
estadd loc thisstat24 = "`r(bstar)'": col`colnum'
estadd loc thisstat25 = "`r(sestar)'": col`colnum'

sigstar bm, prec(3)
estadd loc thisstat26 = "`r(bstar)'": col`colnum'
estadd loc thisstat27 = "`r(sestar)'": col`colnum'

sigstar bm_big, prec(3)
estadd loc thisstat28 = "`r(bstar)'": col`colnum'
estadd loc thisstat29 = "`r(sestar)'": col`colnum'

sigstar male, prec(3)
estadd loc thisstat31 = "`r(bstar)'": col`colnum'
estadd loc thisstat32 = "`r(sestar)'": col`colnum'

sigstar atleast_bachelor, prec(3)
estadd loc thisstat33 = "`r(bstar)'": col`colnum'
estadd loc thisstat34 = "`r(sestar)'": col`colnum'

sigstar republican, prec(3)
estadd loc thisstat35 = "`r(bstar)'": col`colnum'
estadd loc thisstat36 = "`r(sestar)'": col`colnum'

estadd loc thisstat38 "Yes": col`colnum'
estadd loc thisstat39= `r2': col`colnum'
estadd loc thisstat40 = `N': col`colnum'

loc ++colnum
loc colnames "`colnames' `"`: var la `choice''"'"

}

loc rowlabels " " " "$\Delta$ Net income (\%)" " " "$\Delta$ Retirement fin. wealth (\%)" " " "$\Delta$ Other fin. wealth (\%)" " " " " "Ln(Total fin. wealth)" " " "Stock share in ret. wealth" " " "Stock share in ot. fin wealth" " " "Share ret. in tot. fin. wealth" " " " " "Any loss fin. crisis" " " "Big loss fin. crisis" " " "Any loss dot-com" " " "Big loss dot-com" " " "Any loss Black Monday" " " "Big loss Black Monday" " " " " "Male" " " "At least bachelor" " " "Republican" " " " " "Individual controls" "Adj. R-squared" "Observations" " 

forval i = 1/40 {
    loc rowstats "`rowstats' thisstat`i'"
}


esttab * using "Tables\Table1.tex", replace cells(none) booktabs nonotes nomtitles compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
     mgroups("\shortstack{Changed \\ stock \\ share}" "\shortstack{Increased \\ stock \\ share}" "\shortstack{Decreased \\ stock \\ share}" ///
"\shortstack{Plan change \\ stock \\ share}" "\shortstack{Plan incr. \\ stock \\ share}" "\shortstack{Plan decr. \\ stock \\ share}", pattern(1 1 1 1 1 1 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))




	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
